<?php

namespace App\Http\Controllers\MemberCommittee;

use App\Enum\CodeEnum;
use App\Http\Controllers\Api\ApiBaseController;
use App\Services\CommonService;
use App\Services\VillageCommitteeService;
use App\Services\VillagerUserService;
use Illuminate\Http\Request;

class MemberCommitteeController extends ApiBaseController
{

    /**
     * 村委会审核.
     * @author ninetyseven.
     * @date 2023-04-17 23:39
     */
    public function stateAdd(Request $request)
    {
        try {
            $post = $request->post();

            $data = VillageCommitteeService::stateSave($post);
            return success();
        } catch (\Exception $e) {
            return fail(CodeEnum::ERROR, $e->getMessage());
        }
    }

    /**
     * 查询村民列表
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \Exception
     */
    public function userList(Request $request)
    {
        try {
            $get = $request->get();

            $commonInter = CommonService::getCommunity();

            $data = VillagerUserService::getVillagerList($commonInter);
            return success($data);
        } catch (\Exception $e) {
            return fail(CodeEnum::ERROR, $e->getMessage());
        }
    }
}
